package com.dkh.recommend.controller;


import com.dkh.recommend.dto.Result;
import com.dkh.recommend.entity.TbMusic;
import com.dkh.recommend.utils.UserHolder;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import com.dkh.recommend.service.ITbPlaylistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dkh
 * @since 2022-12-14
 */
@Slf4j
@RestController
@Api(value = "", tags = "", description="")
@RequestMapping("/playlist")
public class TbPlaylistController {

    @Autowired
    private ITbPlaylistService playlistService;


//    查看播放列表
    @ApiOperation("查看播放列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "app", value = "查看播放列表", required = true, dataType = "AppDTO", paramType = "body")})
    @GetMapping( "/getmyplaylist")
    public Result getmyplaylist(){
        return playlistService.getmyplaylist();
    }

//    添加音乐到播放列表
    @PostMapping("/add")
    public Result add2PlayList(@RequestBody TbMusic tbMusic){
        return playlistService.add2PlayList(tbMusic);
    }

//    添加多个音乐到播放列表
    @PostMapping("/add2playList2")
    public Result add2playList2(@RequestBody List<TbMusic> musicList){
        return playlistService.add2playList2(musicList);
    }

//    根据MusicId删除播放列表音乐
    @DeleteMapping("/delete")
    public Result delete2PlayList(@RequestParam String musicId){
        return playlistService.delete2PlayList(musicId);
    }

//    删除当前用户播放列表所有音乐
    @DeleteMapping("/deleteall")
    public Result deleteAll2PlayList(){
        return playlistService.deleteAll2PlayList();
    }

//    将收藏夹的音乐添加到播放列表
    @PostMapping("/collect2playlist/{collectId}")
    public Result Collect2playlist(@PathVariable String collectId){
        return playlistService.Collect2playlist(collectId);
    }


}
